/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2023. All rights reserved.
 * Description: UDK memory config sources
 * Author: -
 * Create: 2021.6.22
 */
#include "udk_rwlock.h"
#include "udk.h"
#include "udk_mcfg.h"

void udk_mcfg_tailq_read_lock(void)
{
    struct udk_mem_config *mcfg = udk_get_configuration()->mem_config;
    udk_rwlock_read_lock(&mcfg->qlock);
}

void udk_mcfg_tailq_read_unlock(void)
{
    struct udk_mem_config *mcfg = udk_get_configuration()->mem_config;
    udk_rwlock_read_unlock(&mcfg->qlock);
}

void udk_mcfg_tailq_write_lock(void)
{
    struct udk_mem_config *mcfg = udk_get_configuration()->mem_config;
    udk_rwlock_write_lock(&mcfg->qlock);
}

void udk_mcfg_tailq_write_unlock(void)
{
    struct udk_mem_config *mcfg = udk_get_configuration()->mem_config;
    udk_rwlock_write_unlock(&mcfg->qlock);
}

void udk_mcfg_mempool_read_lock(void)
{
    struct udk_mem_config *mcfg = udk_get_configuration()->mem_config;
    udk_rwlock_read_lock(&mcfg->mplock);
}

void udk_mcfg_mempool_read_unlock(void)
{
    struct udk_mem_config *mcfg = udk_get_configuration()->mem_config;
    udk_rwlock_read_unlock(&mcfg->mplock);
}

void udk_mcfg_mempool_write_lock(void)
{
    struct udk_mem_config *mcfg = udk_get_configuration()->mem_config;
    udk_rwlock_write_lock(&mcfg->mplock);
}

void udk_mcfg_mempool_write_unlock(void)
{
    struct udk_mem_config *mcfg = udk_get_configuration()->mem_config;
    udk_rwlock_write_unlock(&mcfg->mplock);
}

uint32_t udk_memory_get_nchannel(void)
{
    return udk_get_configuration()->mem_config->nchannel;
}

uint32_t udk_memory_get_nrank(void)
{
    return udk_get_configuration()->mem_config->nrank;
}
